﻿Imports drawing.CommonInterfaces.UI.interfaces


Public Class Line
    Implements IShape
    Implements IViewable




    Public point1 As New Point(0, 0)
    Public point2 As New Point(0, 0)
    Dim _pen As New Pen(Color.Azure, 1)

    Public Sub New(ByVal pen As Pen)
        _pen = pen
    End Sub

    Public Function getClippingRcangle() As System.Drawing.Rectangle Implements IShape.getClippingRcangle
        Dim xtemp, ytemp, widthtemp, heighttemp As Integer

        If point2.X > point1.X Then
            xtemp = point1.X
            widthtemp = point2.X - xtemp
        Else
            xtemp = point2.X
            widthtemp = point1.X - xtemp
        End If
        If point2.Y > point1.Y Then
            ytemp = point1.Y
            heighttemp = point2.Y - ytemp
        Else
            ytemp = point2.Y
            heighttemp = point1.Y - ytemp
        End If
        Return New Rectangle(xtemp, ytemp, widthtemp, heighttemp)

    End Function

    Public Property height() As Integer Implements IShape.height
        Get
            Return getClippingRcangle().Height
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property

    Public Property pen() As System.Drawing.Pen Implements IShape.pen
        Get
            Return _pen
        End Get
        Set(ByVal value As System.Drawing.Pen)
            _pen = value
        End Set
    End Property

    Public Property width() As Integer Implements IShape.width
        Get
            Return getClippingRcangle().Width
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property

    Public Property X() As Integer Implements IShape.X
        Get
            Return getClippingRcangle().X
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property

    Public Property Y() As Integer Implements IShape.Y
        Get
            Return getClippingRcangle().Y
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property

    Public Sub draw(ByRef graph As System.Drawing.BufferedGraphics) Implements IViewable.draw
        graph.Graphics.DrawLine(_pen, point1, point2)
    End Sub

    Public Sub resetSize(ByVal size As System.Drawing.Rectangle) Implements IViewable.resetSize

    End Sub

End Class
